package com.unicom.microserv.contest.contest18_web.conf;


import com.unicom.microserv.contest.contest18_web.base.HtmlContextInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 配置静态资源映射
 * @author sam
 * @since 2017/7/16
 */
@Configuration
@Component
public class WebMvcConfig extends WebMvcConfigurerAdapter      /*extends WebMvcConfigurationSupport*/ {


    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        super.addResourceHandlers(registry);
        //将所有/static/** 访问都映射到classpath:/static/ 目录下
        registry.addResourceHandler("/MgrScript/**/*.js").addResourceLocations("classpath:/templates/");
        registry.addResourceHandler("/MgrScript/**/*.css").addResourceLocations("classpath:/templates/");
        registry.addResourceHandler("/Images/**").addResourceLocations("classpath:/static/Images/");
        registry.addResourceHandler("/plug/**").addResourceLocations("classpath:/static/plug/");
        registry.addResourceHandler("/Scripts/**").addResourceLocations("classpath:/static/Scripts/");
        registry.addResourceHandler("/Styles/**").addResourceLocations("classpath:/static/Styles/");
    }


    public void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
    }

    @Bean
    public HtmlContextInfo htmlContextInfo() {
        HtmlContextInfo htmlContextInfo =new HtmlContextInfo();
        htmlContextInfo.setBasePath("");
        htmlContextInfo.setThemes("metro");
        htmlContextInfo.setCharset("UTF-8");
        htmlContextInfo.setLang("zh-CN");
       return  htmlContextInfo;
    }



}